import { ReqPages, ReqsUserParams, User, ChangePwdParams } from "@/api/interface/index";
import httpss from "@/api/http";

/**
 * @name 用户管理模块
 */
// 获取用户列表
export const getList = (params: ReqsUserParams) => {
  console.log("huoq", params);
  return httpss.post<ReqPages>(`/user/list`, params);
};
export const getLists = () => {
  return httpss.get(`/user/all`);
};
// 新增用户
export const addUsers = (params: User.ResUserList) => {
  console.log("新增用户 ", params);
  return httpss.post(`/user/add`, params);
};
// 批量添加用户

// 编辑用户
export const update = (params: User.ResUserList) => {
  console.log("数据编辑", params);
  return httpss.put(`/user/update`, params);
};
//删除用户新接口
export const deleteUserId = (params: { id: string }) => {
  return httpss.delete(`/user/delete`, { params });
};
// 批量删除
export const deleteListId = (params: { id: string[] }) => {
  console.log("删除用户的id", params);
  return httpss.post(`/user/deleteList`, params);
};

// 切换用户状态

// 重置用户密码
export const resetUserPword = (params: { id: number }) => {
  console.log("重置密码", params);
  return httpss.post(`/user/resetPassword`, params);
};

// 导入用户数据
export const UserImport = (parmas: User.ResUserList) => {
  console.log("导入用户数据", parmas);
  return httpss.post(`/user/import`, parmas, {
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};

//下载用户模板
export const UserTemplate = () => {
  return httpss.get(`/user/template`, { responseType: "blob" });
};
//导出用户数据
export const UserExport = () => {
  return httpss.get("/user/export", { responseType: "blob" });
};

// 获取用户状态字典

// 获取用户性别字典
export const getUserGender = () => {
  return httpss.get(`/user/gender`);
};

// 获取用户部门列表

//更新密码
export const ChangePassword = (params: ChangePwdParams) => {
  console.log("修改密码", params);
  return httpss.post(`/user/changePassword`, params);
};
// 获取用户角色字典

//角色接口
export const getUserRole = () => {
  return httpss.get(`/user/role`);
};
